Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft: Fix bytes and str issue #33

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

LuiggiTenorioK
Copy link
Member

In GitLab by @kinow on Jul 6, 2023, 14:58

@dbeltrankyl this fixes the bytes and str` issue, but now I get an error as it's trying to write to the old exp file.

Should we a) check if the old exp file exists, b) use minimal, c) call some function that already does that for us?

Cheers

@LuiggiTenorioK
Copy link
Member Author

In GitLab by @kinow on Jul 6, 2023, 14:59

mentioned in issue es/autosubmit#1075

@LuiggiTenorioK
Copy link
Member Author

In GitLab by @dbeltrankyl on Jul 6, 2023, 15:32

Oh, that is a problem. Do you know why we're setting this? I don't remember.

The issue is that the commit directive doesn't necessarily have to be in the minimal.yml but doesn't need to be inside a file named expdef. So we should discard options a and b.

I think we need to:

  • Automatically find what is the last file that loaded that variable
  • Do the change on that file

If you need to have this faster.. maybe we can go with the b) use minimal for now

@LuiggiTenorioK
Copy link
Member Author

In GitLab by @kinow on Jul 7, 2023, 11:27

I think the idea was to save the commit as using only the URL and branch could point to a newer commit.

Automatically find what is the last file that loaded that variable
Do the change on that file

I think this is the cleanest solution 😥 I will see if I can maybe copy part of the code that retrieves the commit, or split the function into two (one fetches the commit, the other saves into the file). With these two functions, I should be able to use the fixed one that fetches the commit, and then we can work on the fix for the second part that saves it to the config file later.

Thanks @dbeltrankyl !

@LuiggiTenorioK
Copy link
Member Author

In GitLab by @kinow on Jul 7, 2023, 11:27

requested review from @kinow

@LuiggiTenorioK
Copy link
Member Author

In GitLab by @kinow on Jul 7, 2023, 11:27

removed review request for @kinow

@LuiggiTenorioK
Copy link
Member Author

In GitLab by @kinow on Feb 14, 2024, 13:28

p.s. probably for next week or Friday. I will rebase, check if this is still valid, and then write a test with pytest and update the MR 🎉

@LuiggiTenorioK
Copy link
Member Author

In GitLab by @dbeltrankyl on Mar 4, 2024, 13:21

mentioned in merge request es/autosubmit!394

@LuiggiTenorioK
Copy link
Member Author

In GitLab by @dbeltrankyl on May 7, 2024, 09:49

Maybe this needs an update?

@LuiggiTenorioK
Copy link
Member Author

In GitLab by @kinow on May 7, 2024, 10:06

Definitely does, one of the many merge-requests I am pending to update, sorry. Will try to do it over next days. Thanks for the reminder, @dbeltrankyl ! 💪

@LuiggiTenorioK
Copy link
Member Author

In GitLab by @dbeltrankyl on Aug 23, 2024, 15:00

Hello @kinow ,

I see that this is unassigned ( although it could never be assigned) and it is an old merge.

Do you need another person to take care of it? Maybe @egarriga or I can try to write the remaining stuff that I think is the pytest?

@LuiggiTenorioK
Copy link
Member Author

In GitLab by @kinow on Aug 26, 2024, 08:58

Sounds good to me. @egarriga if you have spare time, you can have a look at this one. Otherwise, if I have some minutes by the end of a work day, I might have a stab at it and see if we can close this issue. Thanks @dbeltrankyl !

@LuiggiTenorioK
Copy link
Member Author

In GitLab by @egarriga on Aug 26, 2024, 09:52

I will take a look and work on it

@LuiggiTenorioK
Copy link
Member Author

In GitLab by @kinow on Aug 26, 2024, 13:52

Thank you, Edgar!

@LuiggiTenorioK
Copy link
Member Author

In GitLab by @kinow on Sep 5, 2024, 14:32

@egarriga

image

GitLab UI isn't very intuitive, IMHO (they could have copied GitHub's UI, then improved, instead of renaming pull-request/merge-request, moved things around, etc., IMHO... ).

Opening the issue in AS linked above, you'll find that the issue is when you run "autosubmit clean --project $expid broken due to can only concatenate str (not "bytes") to str".

Looks like I found this when implementing the RO-Crate archive, where I had to test some parts of the code manually first.

Hope that helps!

@LuiggiTenorioK
Copy link
Member Author

In GitLab by @dbeltrankyl on Sep 16, 2024, 12:22

Removing the assigne

@LuiggiTenorioK
Copy link
Member Author

In GitLab by @dbeltrankyl on Sep 16, 2024, 12:22

unassigned @egarriga

@LuiggiTenorioK
Copy link
Member Author

In GitLab by @kinow on Sep 17, 2024, 14:03

requested review from @kinow

@LuiggiTenorioK
Copy link
Member Author

In GitLab by @kinow on Sep 17, 2024, 14:03

removed review request for @kinow

@LuiggiTenorioK
Copy link
Member Author

In GitLab by @kinow on Sep 17, 2024, 14:05

Will manual test, and if that works with AS then will see if I can write a small unit test for this change.

@LuiggiTenorioK
Copy link
Member Author

In GitLab by @kinow on Sep 17, 2024, 19:29

Confirmed that master of Autosubmit still has the issue, after creating an experiment with a Git project.

(autosubmit4) kinow@ranma:~/Development/python/workspace/autosubmit$ autosubmit -lc DEBUG clean --project a022
/home/kinow/Development/python/micromamba/envs/autosubmit4/bin/autosubmit:4: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
  __import__('pkg_resources').require('autosubmit==4.1.10')
/home/kinow/Development/python/micromamba/envs/autosubmit4/lib/python3.9/site-packages/paramiko/pkey.py:100: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from this module in 48.0.0.
  "cipher": algorithms.TripleDES,
/home/kinow/Development/python/micromamba/envs/autosubmit4/lib/python3.9/site-packages/paramiko/transport.py:259: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from this module in 48.0.0.
  "class": algorithms.TripleDES,
Autosubmit admin user: eadmin is not set
Autosubmit is running with 4.1.10

Checking configuration files...
Expdef config file is correct
Platforms sections: OK
Jobs sections OK
Autosubmit general sections OK
Configuration files OK

Registering commit SHA...
Traceback (most recent call last):
  File "/home/kinow/Development/python/workspace/autosubmit/autosubmit/autosubmit.py", line 2872, in clean
    autosubmit_config.set_git_project_commit(autosubmit_config)
  File "/home/kinow/Development/python/micromamba/envs/autosubmit4/lib/python3.9/site-packages/autosubmitconfigparser/config/configcommon.py", line 1910, in set_git_project_commit
    Log.debug("Project branch is: " + project_branch)
TypeError: can only concatenate str (not "bytes") to str

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/kinow/Development/python/workspace/autosubmit/bin/autosubmit", line 59, in main
    return_value = Autosubmit.parse_args()
  File "/home/kinow/Development/python/workspace/autosubmit/autosubmit/autosubmit.py", line 725, in parse_args
    return Autosubmit.clean(args.expid, args.project, args.plot, args.stats)
  File "/home/kinow/Development/python/workspace/autosubmit/autosubmit/autosubmit.py", line 2888, in clean
    raise AutosubmitCritical("Couldn't clean this experiment, check if you have the correct permissions", 7012,
log.log.AutosubmitCritical:  

Trace: can only concatenate str (not "bytes") to str
 [CRITICAL] Couldn't clean this experiment, check if you have the correct permissions [eCode=7012]
More info at https://autosubmit.readthedocs.io/en/master/troubleshooting/error-codes.html

@LuiggiTenorioK
Copy link
Member Author

In GitLab by @kinow on Sep 17, 2024, 19:32

Hmmm, but then updating the version of the config parser in AS' setup.py, and then using this branch, I get another error.

Registering commit SHA...
Project branch is: master

Project commit SHA is: c2672568fb14706c6e66481bc7ceac467db8261e

Traceback (most recent call last):
  File "/home/kinow/Development/python/workspace/autosubmit/autosubmit/autosubmit.py", line 2872, in clean
    autosubmit_config.set_git_project_commit(autosubmit_config)
  File "/home/kinow/Development/python/workspace/autosubmit4-config-parser/autosubmitconfigparser/config/configcommon.py", line 1929, in set_git_project_commit
    content = open(self._exp_parser_file).read()
AttributeError: 'AutosubmitConfig' object has no attribute '_exp_parser_file'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/kinow/Development/python/workspace/autosubmit/bin/autosubmit", line 59, in main
    return_value = Autosubmit.parse_args()
  File "/home/kinow/Development/python/workspace/autosubmit/autosubmit/autosubmit.py", line 725, in parse_args
    return Autosubmit.clean(args.expid, args.project, args.plot, args.stats)
  File "/home/kinow/Development/python/workspace/autosubmit/autosubmit/autosubmit.py", line 2888, in clean
    raise AutosubmitCritical("Couldn't clean this experiment, check if you have the correct permissions", 7012,
log.log.AutosubmitCritical:  

Trace: 'AutosubmitConfig' object has no attribute '_exp_parser_file'
 [CRITICAL] Couldn't clean this experiment, check if you have the correct permissions [eCode=7012]
More info at https://autosubmit.readthedocs.io/en/master/troubleshooting/error-codes.html

@LuiggiTenorioK
Copy link
Member Author

In GitLab by @kinow on Oct 10, 2024, 14:06

added 107 commits

  • e07a7ab2...fa4aaa11 - 106 commits from branch main
  • 30229e1 - Fix bytes and str issue

Compare with previous version

@LuiggiTenorioK
Copy link
Member Author

In GitLab by @kinow on Oct 10, 2024, 14:19

added 1 commit

  • a94e334 - Remove functions not used in Autosubmit, nor here

Compare with previous version

@LuiggiTenorioK
Copy link
Member Author

In GitLab by @kinow on Oct 10, 2024, 14:19

Commented on autosubmitconfigparser/config/configcommon.py line 1788

Not used in this project, nor in Autosubmit.

@LuiggiTenorioK
Copy link
Member Author

In GitLab by @kinow on Oct 10, 2024, 14:19

Commented on autosubmitconfigparser/config/configcommon.py line 2155

Not used here, nor on Autosubmit.

@LuiggiTenorioK
Copy link
Member Author

In GitLab by @kinow on Oct 10, 2024, 14:23

@dbeltrankyl I had a look at this issue today, but I am not sure how to fix it yet.

I removed the only two other places where this _exp_parser_file is used.

However, in autosubmit clean, we set a new git commit in the config, with as_conf.set_git_project_commit. There are other functions here that set values in the config, like as_conf.set_last_as_command and as_conf.set_version.

On these two functions, the idea seems to be write to files with the AS configuration. So as_conf.set_last_as_command writes to as_misc.yml with the AS_MISC: True, and the AS_COMMAND there too.

While set_version writes to version.yml with the CONFIG.AUTOSUBMIT_VERSION.

But what happens if the user has other files being loaded after version.yml and as_misc.yml? Isn't there a risk that these files might be loaded in other order, and the final values for the last command and version might be incorrect?

And for other settings like the git project commit, would it be then the case to create project.yml or something like this in the conf file?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants